<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('选择人员')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>


<script th:inline="javascript">
    var prefix = ctx + "entryExitManage";
    var type;
    $(function () {
        type = [[${type}]];
        queryCompanyList();
    });



    function queryCompanyList() {
        var options = {
            code: "eid",
            uniqueId: "eid",
            url: prefix + "/getEmpList",
            escape: true,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            columns: [{
                radio: true
            },
                {
                    field: 'eid',
                    title: 'eid',
                    visible: false
                },
                {
                    field: 'bgna',
                    title: '用户'
                }]
        };
        $.table.init(options);
    }

    function submitHandler(index, layero) {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var eid = $.table.selectColumns("eid");
        //使用ajax根据eid获取工号、公司名称、部门名称、岗位名称
        getEmpInfo(eid);
        /*
        // 父页面的变量
        if(type == "ReportTo"){
            parent.$('#ReportTo').val(eid);
            parent.$('#ReportToName').val(bgna);
        }else if(type == "WFReportTo"){
            parent.$('#WFReportTo').val(eid);
            parent.$('#WFReportToName').val(bgna);
        }
        */
    }

    function getEmpInfo(eid){
        $.ajax({
            async: false,
            url: ctx + "bgInfo/getEmpInfo",
            data: {
                "eid": eid.toString()
            },
            type: "post",
            dataType: "json",
            success: function (data) {
                $.modal.close();
                parent.$('#eid').val(data.eid);
                parent.$('#badge').val(data.badge);
                parent.$('#name').val(data.name);
                parent.$('#compName').val(data.compName);
                parent.$('#depName').val(data.depName);
                parent.$('#jobName').val(data.jobName);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }
</script>
</body>
</html>
